package com.GDOU.service.serviceImp;

import com.GDOU.bean.Teacher;
import com.GDOU.mapper.TeacherMapper;
import com.GDOU.service.TeacherService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    public Teacher getTeacherById(Integer teaId) {
        return teacherMapper.getTeacherById(teaId);
    }

    @Override
    public int addTeacher(Teacher teacher) {
        return teacherMapper.addTeacher(teacher);
    }

    @Override
    public int deleteTeacher(String teaNum) {
        return teacherMapper.deleteTeacher(teaNum);
    }

    @Override
    public int updateTeacher(Teacher teacher) {
        return teacherMapper.updateTeacher(teacher);
    }

    @Override
    public List<Teacher> getAllTeacher() {
        return teacherMapper.getAllTeacher();
    }


    @Override
    public PageInfo<Teacher> getTeacherPage(Integer pageNum) {
        //开启分页功能
        PageHelper.startPage(pageNum,5);
        //查询所有教师信息
        List<Teacher> teacherList = teacherMapper.getAllTeacher();
        //获取分页数据
        PageInfo<Teacher>page=new PageInfo<>(teacherList,5);
        return page;
    }

    @Override
    public Teacher getTeacherByName(String teaName) {
        return teacherMapper.getTeacherByName(teaName);
    }
}
